//const joi = require('@hapi/joi')

const joi = require('joi');

const username = joi.string().alphanum().min(1).max(10).required()
const password = joi.string().pattern(/^[\S]{6,12}$/).required()



//定义id nickname  email 的验证规则
const id = joi.number().integer().min(1).required()
const nickname = joi.string().required()
const email = joi.string().email().required()




exports.reg_login_schema = {
    body:{
        username,
        password,
    }
}


//更新用户的规则对象
exports.update_userinfo_schema = {
    body:{
        id,
        nickname,
        email
    }
}



//验证密码规则  新密码不能和旧密码一致
exports.update_password_schema = {
    body:{
        oldPwd:password,
        newPwd:joi.not(joi.ref('oldPwd')).concat(password),
    }
}



//定义验证avatar头像的验证规则
const avatar = joi.string().dataUri().required()




//验证规则对象 ----更新头像
exports.update_avatar_schema ={
    body:{
        avatar
    }
}






